<?php
namespace Home\Controller;
use Home\Biz\CommonBiz;
use Home\Biz\SkuBiz;
use Think\Controller;

class SkuController extends LoginBaseController{
	/**
	 * sku列表显示
	 */
	public  function  skuInfo(){
		$this->assign('page_name',	'sku信息列表');
		$this->display('sku/skuinfo');
	}
    
    /**
     * sku详情页面
     */
    public function detailSku(){
    	$sku_id = I('sku_id');
    	//$sku_id = 'SK10772568';
    	$sku_en = M('sku')->where("sku_id='%s'", $sku_id)->find();
    	if(empty($sku_en)){
    		
    		$this->assign("errorMsg","该sku不存在！");
    		$this->display("sku/error");
    		return ;
    	}
    	$this->assign('sku_en', $sku_en);
    	$this->assign('module_id',	'style');
		$this->assign('page_id',	'skuList');
		$this->assign('page_name',	'编辑SKU信息');
		$product_split = SkuBiz::getSplitInfoBySku($sku_id);
		if(empty($product_split)){
			$product_split = array();
			$product_split['referent_id'] = 0;
		}
		$this->assign("product_split" ,$product_split);
		$this->assign("vip_bag_lst" ,SkuBiz::getVipBagLst());
    	$this->display('sku/detailSku');
    }
    
    /**
     * sku详情页面
     */
    public function addSku(){
    	$this->assign('module_id',	'style');
    	$this->assign('page_id',	'skuList');
    	$this->assign('page_name',	'新增SKU信息');
    	//新增时候为不选择
    	$product_split = array();
    	$product_split['referent_id'] = 0;
    	$this->assign("product_split" ,$product_split);
    	$this->assign("vip_bag_lst" ,SkuBiz::getVipBagLst());
    	$this->display('sku/addSku');
    	
    }
    
    public function productinfosearch(){
    	//$product_id = I('product_id');
    	$product_name = I('product_name');
    	$material_no = I('material_no');
    	$lst_product_info = SkuBiz::queryProductInfo(null, $product_name, $material_no, null);
    	$this->assign("lst_product_info", json_encode($lst_product_info));
    	//$this->assign("s_product_id", $product_id);
    	$this->assign("s_product_nme", $product_name);
    	$this->assign("s_material_no", $material_no);
    	$this->assign("product_type_options" ,json_encode(CommonBiz::getOptions("PRODUCT_TYPE")));
    	$this->assign("product_type_lst" ,CommonBiz::getOptions("PRODUCT_TYPE",array(3)));
    	$this->display('sku/productinfosearch');
    	
    }
  
}